export default {
    // 添加命名空间
    namespaced:'car',
    state:{
        carList:[{
            id:Math.random().toString(36).slice(2),
            gname:'华为',
            price:2000,
            buyNum:1
        }]
    },
    getters:{
        totalPrice(state){
            return state.carList.reduce((pre,cur)=>pre + cur.price * cur.buyNum,0)
        }
    },
    actions:{
        addCar(context, goods){ // {gname:'', price:2000}
            console.log('addCar',goods)
        }
    },
    mutations:{
        ADD_CAR(state, car){

        }
    }
}